export DYLD_LIBRARY_PATH := $(CURDIR)/rustc/lib:$(DYLD_LIBRARY_PATH)
endif
+CFG_RELEASE=0.1.0-pre
+CFG_VER_DATE = $(shell git log -1 --pretty=format:'%ai')
+CFG_VER_HASH = $(shell git rev-parse --short HEAD)
+CFG_VERSION = $(PKG_NAME) $(CFG_RELEASE) ($(CFG_VER_HASH) $(CFG_VER_DATE))
+
+export CFG_RELEASE
+export CFG_VER_DATE
+export CFG_VER_HASH
+export CFG_VERSION
+
export PATH := $(CURDIR)/rustc/bin:$(PATH)
# Link flags to pull in dependencies
cargo-verify-project \
cargo-git-checkout \
cargo-test \
- cargo-run
+ cargo-run \
+ cargo-version
SRC = $(shell find src -name '*.rs' -not -path 'src/bin*')
--- /dev/null
+#![crate_name="cargo-version"]
+#![feature(phase)]
+
+extern crate cargo;
+
+#[phase(plugin, link)]
+extern crate hammer;
+
+#[phase(plugin, link)]
+extern crate log;
+
+extern crate serialize;
+
+use std::os;
+use cargo::execute_main_without_stdin;
+use cargo::core::MultiShell;
+use cargo::util::CliResult;
+
+#[deriving(Decodable,Encodable)]
+pub struct Options;
+
+hammer_config!(Options)
+
+
+fn main() {
+ execute_main_without_stdin(execute);
+}
+
+fn execute(_: Options, _: &mut MultiShell) -> CliResult<Option<()>> {
+ debug!("executing; cmd=cargo-version; args={}", os::args());
+
+ println!("{}", env!("CFG_VERSION"));
+
+ Ok(None)
+}
#![feature(phase)]
extern crate cargo;
+#[phase(plugin, link)]
extern crate hammer;
+
extern crate serialize;
+
#[phase(plugin, link)]
extern crate log;
*/
fn execute() {
debug!("executing; cmd=cargo; args={}", os::args());
-
let (cmd, args) = process(os::args());
match cmd.as_slice() {
println!(" test # run the tests");
println!(" clean # remove the target directory");
println!(" run # build and execute src/main.rs");
+ println!(" version # displays the version of cargo");
println!("");
println!("Options (for all commands):\n\n{}", options);
},
_ => {
+ // `cargo --version` and `cargo -v` are aliases for `cargo version`
+ let cmd = if cmd.as_slice() == "--version" || cmd.as_slice() == "-V" {
+ "version".into_string()
+ } else {
+ cmd
+ };
let command = format!("cargo-{}{}", cmd, os::consts::EXE_SUFFIX);
let mut command = match os::self_exe_path() {
Some(path) => {
--- /dev/null
+use support::{project, execs};
+use hamcrest::assert_that;
+
+fn setup() {}
+
+test!(simple {
+ let p = project("foo");
+
+ assert_that(p.cargo_process("cargo-version"),
+ execs().with_status(0).with_stdout(format!("{}\n",
+ env!("CFG_VERSION")).as_slice()));
+})
mod test_shell;
mod test_cargo_cross_compile;
mod test_cargo_run;
+mod test_cargo_version;